
/*!	Sprite is a Behaviour . It take a texture image, and how many animation, size and step	*/
Sprite = function(texture, stepsCount, animCount, animId, delta, entity)
{
	/************************************/
	/*			Properties				*/
	/************************************/
	
	this.m_Texture;			/*!<	Reference to the Spritesheet. The SpriteSheet is a texture storing all animations steps	*/
	
	this.m_AnimationCount;	/*!<	Store how many animations are present inside the SpriteSheet, wich correspond to the number of times the image is repeat in Y	*/
	this.m_StepCount;		/*!< 	Store Frame count by animation				*/
	
	this.m_CurrentAnimation		/*!<	Store the current animation displayed Id						*/
	this.m_CurrentStep;			/*!< 	Store the current Frame Id of the currently displayed animation	*/
		
	this.m_Delta;				/*!< Time between each new animation step	*/
	this.m_Clock;				/*!< Clock use to know when we have to display the next animation frame	*/
	
	/************************************/
	/*			Constructor				*/
	/************************************/

	Behaviour.call(this);
	
	this.m_Texture=texture;
	
	this.m_StepCount=stepsCount;
	this.m_AnimationCount=animCount;
	
	this.m_Entity			=	entity;

	this.m_CurrentAnimation	=animId;
	this.m_CurrentStep	=0;
	
	this.m_Delta=delta;
	
	this.m_Clock	=	new Clock();
}


Sprite.prototype.Update = function()
{
	if(this.m_Clock.TimeElapsed()>this.m_Delta)
	{

		this.m_Clock.Start();
		this.m_CurrentStep = (this.m_CurrentStep+1) % this.m_StepCount;

	}
	
	this.m_Entity.m_OffsetX=	this.m_CurrentStep / this.m_StepCount;
	this.m_Entity.m_OffsetY=	this.m_CurrentAnimation / this.m_AnimationCount;
	
	this.m_Entity.m_ScaleY= 1 / (this.m_AnimationCount);
	this.m_Entity.m_ScaleX= 1 / (this.m_StepCount);
	

}


